<%@ page pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>


<link
	href="${pageContext.request.contextPath}/css1/registercss/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/css1/registercss/font-awesome.min.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/css1/registercss/animate.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/css1/registercss/style.css"
	rel="stylesheet">



<link rel="stylesheet"
	href="${pageContext.request.contextPath}/js1/iCheck/custom.css" />


</head>
<body class="gray-bg">

	<div class="wrapper wrapper-content">

		<!--  <div class="row">
            <div class="col-sm-12">
                <div class="middle-box text-center animated fadeInRightBig">
                    <h3 class="font-bold">这里是页面内容</h3>

                    <div class="error-desc">
                        您可以在这里添加栅格，参考首页及其他页面完成不同的布局
                        <br/><a href="#" class="btn btn-primary m-t">打开主页</a>
                    </div>
                </div>
            </div>
        </div> -->

		<div class="col-sm-12 animated fadeInDown">
			<div class="tabs-container">
				<ul class="nav nav-tabs">
					<li class="active"><a data-toggle="tab" href="#tab-1"
						aria-expanded="true"> 学生列表</a></li>
					<li class=""><a style="padding-bottom: 0px; padding-top: 3px;"><span
							class="btn btn-primary btn-sm" onclick="showAddPop()">添加用户</span></a></li>
				</ul>
				<div class="tab-content">
					<div id="tab-1" class="tab-pane active">
						<div class="panel-body">
							<div class="col-sm-12">
								<div class="ibox float-e-margins">
									<div class="">
										<div class="row">
											
											<div class="col-sm-4 m-b-xs"></div>
											<div class="col-sm-3">
												<div class="input-group">
													<input type="text" placeholder="请输入关键词" name="zhi"
														class="input-sm form-control"> <span
														class="input-group-btn">
														<button type="button" class="btn btn-sm btn-primary" onclick="soushuo()">
															搜索</button>
													</span>
												</div>
											</div>
										</div>
										<br />
										<div class="table-responsive">
											<table class="table table-striped table-bordered">
												<thead>
													<tr>
														<th>姓名</th>
														<th>生日</th>
														<th>地址</th>
														<th>邮箱</th>
														<th>QQ</th>
														<th>微信</th>
														<th>备注</th>
														<th>修改</th>
														<th>删除</th>

													</tr>
												</thead>
												<tbody>

													<c:forEach var="selectAll" items="${selectAll}">
														<tr>
															<td>${selectAll.purchase_name}</td>
															<td>${selectAll.brithday}</td>
															<td>${selectAll.address}</td>
															<td>${selectAll.email}</td>
															<td>${selectAll.qq_num}</td>
															<td>${selectAll.weixin_num}</td>
															<td>${selectAll.remark}</td>

															<td><span style="cursor: pointer"
																onclick="updataThis(${selectAll.purchase_people_id})"><i
																	class=" fa fa-eyedropper "></i></span></td>
															<td><div class="btn btn-danger"
																	onclick="deleteThis(${selectAll.purchase_people_id});">
																	<span class="glyphicon glyphicon-remove"></span> 删除
																</div></td>
														</tr>
													</c:forEach>
												</tbody>
											</table>
										</div>
								   <div  id="page" style="text-align:center"></div> 
									</div>
									 
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 全局js -->
	<script
		src="${pageContext.request.contextPath}/js1/registerjs/jquery.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/js1/registerjs/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/js1/registerjs/jquery.metisMenu.js"></script>
	<script
		src="${pageContext.request.contextPath}/js1/registerjs/jquery.slimscroll.min.js"></script>

	<script
		src="${pageContext.request.contextPath}/js1/registerjs/layer-v3.1.1/layer/layer.js"></script>

	<!-- 自定义js -->
	<script src="${pageContext.request.contextPath}/js1/registerjs/hplus.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/js1/registerjs/contabs.js"></script>

	<!-- 第三方插件 -->

	<script src="${pageContext.request.contextPath}/js1/iCheck/icheck.min.js"></script>

	<script src="${pageContext.request.contextPath}/js1/registerjs/pace.min.js"></script>

	<script
		src="${pageContext.request.contextPath}/js1/jquery-bootstrap-pagination/jquery-bootstrap-pagination.js"></script>

	<script
		src="${pageContext.request.contextPath}/js1/Huploadify-master/jquery.Huploadify.js"></script>
</body>
<script>
//通过ID删除对应数据

<%-- 	function deleteThis(purchase_people_id) {
			if(confirm("确定删除吗？")){
				location="<%=request.getContextPath()%>/Purchase_People_TbServlet/delete?purchase_people_id="+purchase_people_id;
			
		}
	}
 --%>

 
 	
 
 
	function deleteThis(purchase_people_id){
		if(confirm('确定删除此用户吗？')){
			$.get('${pageContext.request.contextPath}/Purchase_People_TbServlet/updateDelete',{'purchase_people_id':purchase_people_id},function(data){
				alert(data)
				if(data){
					layer.msg('删除成功');
					location.reload();
				}else{
					layer.msg('删除失败');
				}
			});
		}
	}

	//弹出添加表单框:
	function showAddPop(){
	 parent.layer.open({
 			type:2,
 			content:['${pageContext.request.contextPath}/Purchase_People_TbServlet/preAdd'],
 			area:['65%','75%'],
 			offset:['10%','20%'],
 			/* fix: false, */
 			
 		});

 }
 
	//弹出修改表单框:
	function updataThis(purchase_people_id){
	 	 parent.layer.open({
		 			type:2,
		 			content:['${pageContext.request.contextPath}/Purchase_People_TbServlet/preEdit?purchase_people_id='+purchase_people_id],
		 			area:['65%','75%'],
		 			offset:['10%','20%'],
		 			/* fix: false, */
		 		});
		 }

	 $("#page").pagination({
		  total_pages:${pageCount},
		  current_page: ${pageNum},
		  next: "下一页",
		  prev: "上一页",
		  display_max: 4,
		  callback: function(event, page) {
		     /* return alert("Page " + page + " was clicked!");  */
		 	  location="${pageContext.request.contextPath}/Purchase_People_TbServlet/listByPage?pageNum="+page;
		  }
		}); 
 
	 
	 function soushuo(){
		 search=$('[name=zhi]').val();
	        location="${pageContext.request.contextPath}/Purchase_People_TbServlet/listAllSearchPagination?search="+search;  
	}
</script>
</html>
